package com.haogu.controller;

import com.haogu.entity.User;
import com.haogu.service.RecordService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Map;

@Controller
@RequestMapping("/marketing")
public class MarketingController {
    @Resource
    private RecordService recordService;
    /**
     * 去营销的主页面
     */
    @RequestMapping("/toEmailMarketing")
    public String toEmailMarketing(){
        return "marketing/email_marketing";
    }
    /**
     * 去发送短信页面
     */
    @RequestMapping("/toSendMsg")
    public String toSendMsg(){
        return "marketing/sendmsg_marketing";
    }
    /**
     * 去短信发件箱页面
     */
    @RequestMapping("toListMessage")
    public String toListMessage(){
        return "marketing/list_message";
    }
    /**
     * 去发送邮件页面
     */
    @RequestMapping("/toSendMail")
    public String toSendMail(Model model, HttpSession session){

        User user = (User)session.getAttribute("user");
        String sender = user.getEmail();

        model.addAttribute("zipcode","749165249@qq.com");
        model.addAttribute("email",sender);
        return "marketing/sendemail_marketing";
    }
    /**
     * 展示收件箱页面数据
     */
    @RequestMapping("/listMessage")
    @ResponseBody
    public Map listMessage(Integer page,Integer rows){
        Map map = recordService.selectVRcordByPage(page, rows);
        return map;
    }
}

